# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhaseConfig do
  @moduledoc """
  Configuration for any new locations Play may launch in for a single offer phase.

  ## Attributes

  *   `absoluteDiscounts` (*type:* `GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhasePrices.t`, *default:* `nil`) - The absolute amount of money subtracted from the base plan price prorated over the phase duration that the user pays for this offer phase. For example, if the base plan price for this region is $12 for a period of 1 year, then a $1 absolute discount for a phase of a duration of 3 months would correspond to a price of $2. The resulting price may not be smaller than the minimum price allowed for any new locations Play may launch in.
  *   `free` (*type:* `GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhaseFreePriceOverride.t`, *default:* `nil`) - Set to specify this offer is free to obtain.
  *   `otherRegionsPrices` (*type:* `GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhasePrices.t`, *default:* `nil`) - The absolute price the user pays for this offer phase. The price must not be smaller than the minimum price allowed for any new locations Play may launch in.
  *   `relativeDiscount` (*type:* `float()`, *default:* `nil`) - The fraction of the base plan price prorated over the phase duration that the user pays for this offer phase. For example, if the base plan price for this region is $12 for a period of 1 year, then a 50% discount for a phase of a duration of 3 months would correspond to a price of $1.50. The discount must be specified as a fraction strictly larger than 0 and strictly smaller than 1. The resulting price will be rounded to the nearest billable unit (e.g. cents for USD). The relative discount is considered invalid if the discounted price ends up being smaller than the minimum price allowed in any new locations Play may launch in.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :absoluteDiscounts =>
            GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhasePrices.t() | nil,
          :free =>
            GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhaseFreePriceOverride.t()
            | nil,
          :otherRegionsPrices =>
            GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhasePrices.t() | nil,
          :relativeDiscount => float() | nil
        }

  field(:absoluteDiscounts,
    as: GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhasePrices
  )

  field(:free,
    as: GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhaseFreePriceOverride
  )

  field(:otherRegionsPrices,
    as: GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhasePrices
  )

  field(:relativeDiscount)
end

defimpl Poison.Decoder,
  for: GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhaseConfig do
  def decode(value, options) do
    GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhaseConfig.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferPhaseConfig do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
